package com.rpay.admin.controller.basic;

import com.rpay.admin.param.basic.UpdateBasic;
import com.rpay.common.dto.basic.BasicDTO;
import com.rpay.common.dto.basic.BasicQueryDTO;
import com.rpay.common.vo.PcsResult;
import com.rpay.service.basic.IBasicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author XXX
 * @mail XXX@hotmail.com
 * @date 2018/5/13
 * @Description:后台管理系统基础信息维护
 */
@RestController
@RequestMapping(value = "api/basic")
@Validated
public class BasicController {

    @Autowired
    private IBasicService iBasicService;

    @GetMapping(value = "")
    public PcsResult List() {
        BasicQueryDTO data = iBasicService.getDataList();
        return PcsResult.build(data);
    }

    @PatchMapping(value = "")
    public PcsResult update(@Validated @RequestBody UpdateBasic updateBasic) {
        BasicDTO basicDTO = new BasicDTO();
        basicDTO.setCode(updateBasic.getCode());
        basicDTO.setName(updateBasic.getName());
        basicDTO.setEnName(updateBasic.getEnName());
        basicDTO.setContent(updateBasic.getContent());
        basicDTO.setEnContent(updateBasic.getEnContent());
        iBasicService.updateBasic(basicDTO);
        return new PcsResult();
    }

}
